package SimulateServer// ActionScript file
{
	import Classes.Managers.M_Communication;
	
	import com.adobe.serialization.json.JSON;
	
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class ServerMain
	{
		private static var _instance:ServerMain;/*静态引用*/
		private var _resultObj:Object;/*消息处理结果*/
		public function ServerMain():void
		{
			_instance=this;
			new ServerMsgDeal;
		} 
		
		public function receive(dataStr:String):void
		{
			this._resultObj=ServerMsgDeal.instance.dealMsg(JSON.decode(dataStr));
			var t:Timer=new Timer(100,1);
			t.addEventListener(TimerEvent.TIMER,timerHandle);
			t.start();
		}
		
		private function timerHandle(e:TimerEvent):void
		{
			(e.target as Timer).removeEventListener(TimerEvent.TIMER,timerHandle);
			M_Communication.instance.testLoadOverHandle(JSON.encode(this.resultObj));
		}

		public static function get instance():ServerMain
		{
			return _instance;
		}

		public function get resultObj():Object
		{
			return _resultObj;
		}


	}
}